/* SKU接口模块 */
import httpInstance from '@/utils/http'
/* TS类型 */
import type { resProduct } from './skuTypes'
/* 统一管理接口 */
enum API {
  /* 获取全部信息 */
  GET_PRODUCT_LIST = '/admin/product/list/',
  //上架
  SALE_URL = '/admin/product/onSale/',
  //下架的接口
  CANCELSALE_URL = '/admin/product/cancelSale/',
  //获取商品详情的接口
  SKUINFO_URL = '/admin/product/getSkuInfo/',
  //删除已有的商品
  DELETESKU_URL = '/admin/product/deleteSku/',
}
/* 获取全部信息 */
export const getProductListAPI = ({ page, limit }: any) => {
  return httpInstance.get<any, resProduct>(
    API.GET_PRODUCT_LIST + `${page}/${limit}`,
  )
}
/* 上架商品 */
export const reqSaleAPI = (skuID: number | string) => {
  return httpInstance.get<any, any>(API.SALE_URL + skuID)
}
/* 下架商品 */
export const cancelSaleAPI = (skuID: number | string) => {
  return httpInstance.get<any, any>(API.CANCELSALE_URL + skuID)
}
/* 查看商品 */
export const skuInfoAPI = (skuID: number | string) => {
  return httpInstance.get<any, any>(API.SKUINFO_URL + skuID)
}
/* 删除SKU */
export const deletSkuAPI = (skuID: number | string) => {
  return httpInstance.delete<any, any>(API.DELETESKU_URL + skuID)
}
